package com.darcye.clear.work;

import java.io.File;
import java.io.FilenameFilter;

import com.darcye.clear.utils.DeleteLogger;

/**
 * 扫描和清理Id <br/>
 * 
 * 目标文件：values(*)目录下的所有文件
 * @author Darcy
 * @date 2014-10-10 下午4:53:23
 * @version V1.0
 */
public class IdWorker extends BaseWorker {
	
	private DeleteLogger logger = new DeleteLogger("Id");
	
	private final FilenameFilter mIdFileFliter = new FilenameFilter() {
		public boolean accept(File file, String fileName) {
			if(file.getParentFile() == null || !file.isFile()) return false;
			String pPathName = file.getParentFile().getName();
			return pPathName.startsWith("values");
		}
	};
	
	/**
	 * 关联的资源作为构造方法参数
	 * @param javaWorker
	 * @param layoutWorker
	 * @param menuWorker
	 * @param styleWorker
	 */
	public IdWorker(JavaWorker javaWorker,LayoutWorker layoutWorker,MenuWorker menuWorker,StyleWorker styleWorker){
		mUsedIdIdSet.addAll(javaWorker.getUsedIdIdSet());
		mUsedIdIdSet.addAll(layoutWorker.getUsedIdIdSet());
		mUsedIdIdSet.addAll(menuWorker.getUsedIdIdSet());
		mUsedIdIdSet.addAll(styleWorker.getUsedIdIdSet());
	}
	
	public void execute() {
		setLogger(logger);
		executeForTerminalId(mIdFileFliter, "id", mUsedIdIdSet);
	}

}
